package com.wlsk.license.service.feign;

import com.wlsk.license.common.constant.FeignServiceConstant;
import com.wlsk.license.common.result.Result;
import com.wlsk.license.dto.request.feign.GetOssObjectUrlReqDto;
import com.wlsk.license.dto.response.feign.OssObjectInfoResultDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

/**
 * @description: oss文件服务
 * @author: liuzhangbin
 * @date: 2025/2/21
 */
@Component
@FeignClient(value = FeignServiceConstant.PLAT_OSS, contextId = "platOssFeignClient")
public interface PlatOssFeignClient {

    /**
     * 根据文件ID获取文件信息
     *
     * @param reqDto
     * @return
     */
    @PostMapping("plat/getOssObjectUrl")
    Result<OssObjectInfoResultDto> getOssObjectUrl(@RequestBody GetOssObjectUrlReqDto reqDto);

    /**
     * 文件上传
     *
     * @param ossObject 文件内容
     * @param position  文件位置
     * @return
     */
    @PostMapping(value = "plat/uploadOssObject", headers = {"content-type=multipart/form-data"})
    Result<OssObjectInfoResultDto> uploadOssObject(@RequestPart("ossObject") MultipartFile ossObject, @RequestParam("position") Integer position);
}
